Skip to content

some higher volume mods for the vps#765

Draft
tavdog wants to merge 15 commits intomainfrom
dev
Draft

some higher volume mods for the vps#765
tavdog wants to merge 15 commits intomainfrom
dev

Conversation

@tavdog
Copy link
Member

@tavdog tavdog commented Mar 23, 2026

Might keep this as a high device / volume branch but just wanted to see what gemini was going to complain about.
admin dash,
10 sec stats in log output
default 5 render slots avaailable, return cached if no slots avail.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the system's operational visibility and resource management by introducing a new administrative dashboard and implementing a concurrent rendering control mechanism. The changes provide administrators with detailed real-time metrics on rendering performance and WebP serving, while also ensuring system stability under high load by limiting simultaneous render processes. This allows for better monitoring and optimization of the application's performance, particularly in high-volume environments.

Highlights

  • Admin Dashboard Implemented: A new administrative dashboard has been added, providing real-time insights into system performance, user statistics, and device activity. It includes metrics for WebP serving, render processes, and overall system load, with an auto-refresh feature.
  • Concurrent Render Limiting: A semaphore mechanism has been introduced to limit the number of concurrent rendering operations. This prevents resource exhaustion by ensuring that only a configurable maximum number of renders (defaulting to 5) can run simultaneously. If no render slot is available, a cached image is returned if valid.
  • Enhanced Metrics and Logging: Comprehensive metrics for render requests, active renders, queued renders, render durations, WebP serves, bytes served, and unique devices have been integrated. These statistics are periodically logged every 10 seconds and displayed on the new admin dashboard.
  • Configurable Render Slots: The maximum number of concurrent renders can now be configured via the MAX_CONCURRENT_RENDERS environment variable, allowing for fine-tuning of resource usage based on deployment needs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new admin dashboard with real-time metrics for rendering and WebP serving, including total users, devices, active/queued renders, and WebP traffic. It also implements a configurable semaphore (MAX_CONCURRENT_RENDERS) to limit concurrent rendering operations, with logic to prioritize renders for uncached images. Review comments suggest adding documentation for the default MAX_CONCURRENT_RENDERS value and validation for negative inputs, improving error logging for WebP metrics, and adding unit tests for the getLoadAverage utility function.

TrustedProxies string `env:"TRONBYT_TRUSTED_PROXIES" envDefault:"*"`
LogLevel string `env:"LOG_LEVEL" envDefault:"INFO"`
EnableUpdateChecks bool `env:"ENABLE_UPDATE_CHECKS" envDefault:"true"`
MaxConcurrentRenders int `env:"MAX_CONCURRENT_RENDERS" envDefault:"5"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's good to provide a default value for MaxConcurrentRenders, but consider adding a comment explaining why 5 was chosen as the default. Is it based on testing or hardware constraints? This will help future maintainers understand the rationale behind the default value.

Also, consider adding a validation to ensure that the value is not negative, and log a warning if it is.

Comment on lines +112 to +113
webpMetrics.RecordWebPServed(0)
webpMetrics.RecordUniqueDevice(device.ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It seems like webpMetrics.RecordWebPServed(0) and webpMetrics.RecordUniqueDevice(device.ID) are called when there is an error. It might be useful to log the error message along with these metrics to provide more context for debugging.

Comment on lines +177 to +179
loadAvg1m := getLoadAverage()
if served > 0 {
slog.Info(fmt.Sprintf("Stats ------ : %.1f - %d / %d ", loadAvg1m, served, renders))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a unit test for getLoadAverage() to ensure it returns a valid value, or handles errors gracefully. This is important because the function reads from a file, which could fail.

tavdog and others added 4 commits March 22, 2026 23:43
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant